import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

/**
 * User: Ryan Green
 * Date: 10/12/11
 * Time: 7:34 PM
 * Copyright - University of South Australia
 */
public class MetaDataWindow extends JDialog{
	public MetaDataWindow() {
		super();
		Container contents = getContentPane();
		contents.setLayout(new BorderLayout());
		setTitle("nanoTOF Metadata");
		this.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
		setLocationRelativeTo(null);

		this.setModal(true);

		JPanel inputPanel = new JPanel(new GridLayout(16,3));

		//The input fields
		inputPanel.add(new JLabel("Experiment Name:"));
		inputPanel.add(new JTextField());
		inputPanel.add(new JLabel(""));

		inputPanel.add(new JLabel("Description:"));
		inputPanel.add(new JEditorPane());
		inputPanel.add(new JLabel(""));

		inputPanel.add(new JLabel("Acquisition Time:"));
		inputPanel.add(new JTextField());
		inputPanel.add(new JLabel("(seconds)"));

		inputPanel.add(new JLabel("Comment:"));
		inputPanel.add(new JTextField());
		inputPanel.add(new JLabel(""));

		inputPanel.add(new JLabel("Date Acquired:"));
		inputPanel.add(new JTextField("13/10/2011"));
		inputPanel.add(new JLabel(""));

		inputPanel.add(new JLabel("Dose Rate:"));
		inputPanel.add(new JTextField("4.2E+009"));
		inputPanel.add(new JLabel("(ion/sec-cm²)"));

		inputPanel.add(new JLabel("Integral:"));
		inputPanel.add(new JTextField("254834"));
		inputPanel.add(new JLabel(""));

		inputPanel.add(new JLabel("Ion Polarity:"));
		inputPanel.add(new JTextField("+"));
		inputPanel.add(new JLabel(""));

		inputPanel.add(new JLabel("Primary Gun:"));
		inputPanel.add(new JTextField("LMIG"));
		inputPanel.add(new JLabel(""));

		inputPanel.add(new JLabel("Prim. Particle:"));
		inputPanel.add(new JTextField("N/A"));
		inputPanel.add(new JLabel(""));

		inputPanel.add(new JLabel("Raster Area:"));
		inputPanel.add(new JTextField("4.0E-004"));
		inputPanel.add(new JLabel("(cm²)"));

		inputPanel.add(new JLabel("Raster Size:"));
		inputPanel.add(new JTextField("200.0 x 200.0"));
		inputPanel.add(new JLabel("(µm²)"));

		inputPanel.add(new JLabel("Raster Type:"));
		inputPanel.add(new JTextField("scatter"));
		inputPanel.add(new JLabel(""));

		inputPanel.add(new JLabel("Sample Dose:"));
		inputPanel.add(new JTextField("2.5E+011"));
		inputPanel.add(new JLabel("(ion/cm²)"));

		inputPanel.add(new JLabel("Time/Channel:"));
		inputPanel.add(new JTextField("128"));
		inputPanel.add(new JLabel("(ps)"));

		inputPanel.add(new JLabel("Time Recorder:"));
		inputPanel.add(new JTextField("Multi-Stop TDC"));
		inputPanel.add(new JLabel(""));

		contents.add(inputPanel, BorderLayout.CENTER);


		JPanel buttonPanel = new JPanel(new FlowLayout());

		//the buttons
		JButton loginButton = new JButton("Submit");
		loginButton.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent event) {
				setVisible(false);
				dispose();
			}
		});
		buttonPanel.add(loginButton);

		// space
		//buttonPanel.add(Box.createRigidArea(new Dimension(5, 0)));

		// cancel button
		JButton cancelButton = new JButton("Cancel");
		cancelButton.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent event) {
				setVisible(false);
				dispose();
			}
		});
		buttonPanel.add(cancelButton);

		contents.add(buttonPanel, BorderLayout.SOUTH);


		getRootPane().setDefaultButton(loginButton);
		pack();
	}
}
